<template>
  <div>
    <!-- 输入框 -->
    <el-form @submit.native.prevent :inline="true" size="small" class="demo-form-inline" label-width="80px">
      <el-form-item label="医生名称">
        <el-input @keyup.native.enter="submit" v-model="name" placeholder="请输入医生姓名"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submit">查询</el-button>
      </el-form-item>
    </el-form>

    <el-divider content-position="left">医院列表</el-divider>


    <el-table :data="result">
      <el-table-column label="医生头像" prop="doctor_avatar" width="120px" align="center">
        <template slot-scope="scope">
        <img :src="scope.row.doctor_avatar" alt="" width="80px" height="60px">
      </template> 
      </el-table-column>
      <el-table-column label="医生姓名" prop="doctor_name" align="center" width="100px"></el-table-column>
      <el-table-column label="医生性别" prop="doctor_sex" width="80px" align="center">
        <template slot-scope="scope">
          {{ scope.row.docotr_sex = 1  ? '男' : '女'}}
      </template>
      </el-table-column>
      <el-table-column label="医生职称" prop="doctor_titles" width="80px" align="center"></el-table-column>
      <el-table-column label="医生擅长" prop="doctor_great" align="center" show-overflow-tooltip></el-table-column>
      <el-table-column label="操作" width="180px" align="center">
        <template slot-scope="scope">
          <el-button size="small" type="success" icon="el-icon-check" circle></el-button>
        <el-button size="small" type="info" icon="el-icon-message" circle></el-button>
        <el-button
        @click="$router.push('/home/hospital-update/'+scope.row.h_id)"
        size="small" type="warning" icon="el-icon-edit" circle></el-button>
        <el-button
        @click="deleteItem(scope.row)"
         size="small" type="danger" icon="el-icon-delete" circle></el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination
    @current-change="changeCurrentPage"
     style="margin:10px"
     layout="->,total,prev,pager,next,slot,jumper"
     :total="doctor.total"
     :page-size="doctor.pagesize"
     :current-page="doctor.page"
     background></el-pagination>

  </div>
</template>

<script>
import httpApi from '@/http';
  export default {
    data() {
      return {
        name:'',
        doctor:{
          page:1, // 当前页码
          pagesize:3, // 每页多少条
          total:0, // 总条目数
        },
        result:[], // 医生数据
      }
    },
    methods: {
        queryAllLimt() {
          let params = {page:1,pagesize:5}
          httpApi.doctorApi.queryAlllimit(params).then(res =>{
            console.log('医生列表',res);
            this.doctor = res.data.data
            this.result = res.data.data.result
          })
        },
        changeCurrentPage(page){
      console.log(page);
      this.doctor.page = page // 修改当前页
 
      // this.queryAll()
      
    },
    // 根据姓名查找医生
    queryByName(){
      httpApi.doctorApi.queryByName({doctor_name:this.name}).then(res =>{
        console.log('医生',res);
        this.result = res.data.data
      })
    },
    submit(){
      if(this.name.trim()){
        this.queryByName()
      }else {
        this.queryAllLimt()
      }
    },
      },
      mounted(){
        this.queryAllLimt()
      }
  }
</script>

<style lang="scss" scoped>

</style>